/**
 * @file e2_t2_q6.c
 * @date 2022-03-04
 * 
 * @copyright Copyright (c) 2022 cnzyx MIT Licence
 * 
 */

#include<stdio.h>
#include<stdlib.h>

long fun(int a,int n){
    static int flag=1;
    long temp=a;
    if(n==1){
        return a;
    }
    else{
        for(int i=1;i<n;i++){
            temp*=10;
            temp+=a;
        }
        if(flag){
            flag=0;
            return temp-fun(a,n-1);
        }
        return temp+fun(a,n-1);
    }
}

int main(int argc, char const *argv[])
{
    //UTF-8
    system("chcp 65001");
    int in_num1,in_num2;
    long result;
    printf("请输入组成整数的‘a’：");
    scanf("%d,",&in_num1);
    printf("请输入组成整数的‘n’：");
    scanf("%d,",&in_num2);
    result=fun(in_num1,in_num2);
    printf("结果：%ld\n",result);
    
    //Pause console
    system("pause");
    return 0;
}
